package com.cxt.weather.service;

import cn.hutool.http.HttpUtil;

/**
 * @Author: liuyong
 * @Date: 2019-04-07 16:22
 * @Version 1.0
 */
public class WeatherService {
    /**
     * 单例获取天气服务对象
     * @return
     */
    public static WeatherService getInstance() {
        return new WeatherService();
    }

    /**
     * https://www.cnblogs.com/danyueweb/p/3521973.html
     * http://www.weather.com.cn
     * 根据城市ID查询城市天气预报
     * 请求地址 例子 : http://www.weather.com.cn/data/cityinfo/101010100.html
     * @param cityCode
     * @return
     */
    public String getCityWeather(String cityCode) {
        String url = "http://www.weather.com.cn/data/cityinfo/%s.html";
        url = String.format(url, cityCode);
        return HttpUtil.get(url);
    }
}
